home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / FREQ.TST / FREQTST.C < prev    next >
C/C++ Source or Header  |  1996-03-26  |  2KB  |  84 lines

  1. /* ============ */
  2. /* freqtst.c    */
  3. /* ============ */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7. #include <time.h>
  8.  
  9. #include <mconf.h>
  10. #include <miscdefs.h>
  11. #include <freqdefs.h>
  12.  
  13. #define    FULL_SIZE  ((unsigned)RAND_MAX + 1U)
  14. UINT    WorkArea[FULL_SIZE];
  15.  
  16. #include "execkosm.c"
  17. #include "chisqfrq.c"
  18. #include "ksfreq.c"
  19. #include "exchisq.c"
  20. /* ===================================================================== */
  21. /* freqtst - checks randomness of frequency of numbers produced by rand  */
  22. /* ===================================================================== */
  23. void
  24. main()
  25. {
  26.     CHISQ_STRU        ChiSqData;
  27.     INIT_DATA_STRU  InitialData;
  28.     KS_DATA_STRU    KSData;
  29.  
  30.     char    TestType = 0;
  31.  
  32.     AbortGracefully();            /* Make ^C act reasonably */
  33.  
  34.     printf("\tF R E Q U E N C Y  T E S T\n\n");
  35.     GetInitialData(&InitialData);
  36.     fflush(NULL); fprintf(stderr, "\n");
  37.  
  38.     /* -------------------------- */
  39.     /* Print Initial Data Entries */
  40.     /* -------------------------- */
  41.     printf("Starting Seed = %u%s\n", InitialData.UserSeed,
  42.     (InitialData.SeedSrce == (UINT)(-1)) ?
  43.         " (Unsigned Integer Part of Time of Day)" : "");
  44.  
  45.     printf("Generator     = %s\n", InitialData.GenName);
  46.     fflush(NULL);
  47.     GetChr("\nEnter Type of Test:"
  48.        "\n\tC = Chi-Square"
  49.        "\n\tK = Kolmogorov-Smirnov: ", &TestType);
  50.     fflush(NULL); printf("\n");
  51.  
  52.     TestType = (char)toupper(TestType);
  53.  
  54.     if (TestType == 'C')
  55.     {
  56.     printf("Test Type     = Chi-Square\n");
  57.  
  58.     /* -------------------- */
  59.     /* Address of Generator */
  60.     /* -------------------- */
  61.     ChiSqData.RandFun = InitialData.RandFun;
  62.  
  63.     /* ----------------------- */
  64.     /* Execute Chi-Square Test */
  65.     /* ----------------------- */
  66.     ExecChiSqTest(&ChiSqData);
  67.     }
  68.     else
  69.     {
  70.     printf("Test Type     = Kolmogorov-Smirnov\n");
  71.  
  72.     /* -------------------- */
  73.     /* Address of Generator */
  74.     /* -------------------- */
  75.     KSData.RandFun = InitialData.RandFun;
  76.  
  77.     /* ----------------------- */
  78.     /* Execute Chi-Square Test */
  79.     /* ----------------------- */
  80.     ExecKolSmirTest(&KSData);
  81.     }
  82.     printf("End Test of %s Generator\n", InitialData.GenName);
  83. }
  84.